import pandas as pd
import numpy as np
from tkinter import filedialog
import os

def handle():
    dirs = filedialog.askdirectory()
    for root,dirs,files in os.walk(dirs):
        for filenames in files:
            time = input("时间戳: ")
            filename = os.path.join(root,filenames)
            data = pd.read_csv(filename,engine='python')
            data['时间戳'] = time #设置新列的名字
            data.to_csv(r"C:\Users\tujuan\Desktop\光猫数据\{}".format(filenames), mode = 'a', index =False)
            #mode=a，以追加模式写入,header表示列名，默认为true,index表示行名，默认为true，再次写入不需要行名
    

if __name__ == "__main__":
    handle()
    #zhongxing()
    print("数据处理完毕")